<?xml version="1.0" encoding="utf-8" ?>
<sqlMap namespace="TEngineer" xmlns="http://ibatis.apache.org/mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<alias>
    <typeAlias alias="TEngineer" type="EIA.PM.Model.TEngineer, EIA.PM.Model" />
</alias>

<resultMaps>
<resultMap id="select-tengineer-result" class="TEngineer">
<constructor>
    <argument argumentName="eng_id" column="eng_id"/>
    <argument argumentName="stf_id" column="stf_id"/>
    <argument argumentName="stf_name" column="stf_name"/>
    <argument argumentName="eng_type" column="eng_type"/>
    <argument argumentName="eng_alias" column="eng_alias"/>
</constructor>
<!--
    <result property="EngId" column="eng_id"/>
    <result property="StfId" column="stf_id"/>
    <result property="StfName" column="stf_name"/>
    <result property="EngType" column="eng_type"/>
    <result property="EngAlias" column="eng_alias"/>
-->
</resultMap>
</resultMaps>

<statements>
<sql id="sql_TEngineer_where_pk">
WHERE eng_id=#EngId#
</sql>

<sql id="sql_TEngineer_where_cv">
<dynamic prepend="WHERE">
    <isPropertyAvailable property="EngId" prepend="AND">eng_id=#EngId#</isPropertyAvailable>
    <isPropertyAvailable property="StfId" prepend="AND">stf_id=#StfId#</isPropertyAvailable>
    <isPropertyAvailable property="StfName" prepend="AND">stf_name LIKE concat('%', #StfName#, '%')</isPropertyAvailable>
    <isPropertyAvailable property="EngType" prepend="AND">eng_type=#EngType#</isPropertyAvailable>
    <isPropertyAvailable property="EngAlias" prepend="AND">eng_alias LIKE concat('%', #EngAlias#, '%')</isPropertyAvailable>
</dynamic>
</sql>

<sql id="sql_TEngineer_set_cols">
<dynamic prepend="SET">
    <isPropertyAvailable property="StfId" prepend=",">stf_id=#StfId#</isPropertyAvailable>
    <isPropertyAvailable property="StfName" prepend=",">stf_name=#StfName#</isPropertyAvailable>
    <isPropertyAvailable property="EngType" prepend=",">eng_type=#EngType#</isPropertyAvailable>
    <isPropertyAvailable property="EngAlias" prepend=",">eng_alias=#EngAlias#</isPropertyAvailable>
</dynamic>
</sql>

<select id="SelectTEngineer" parameterClass="" resultMap="TEngineer.select-tengineer-result">
SELECT *
FROM t_engineer
<include refid="sql_TEngineer_where_pk"/><!--where-->
</select>

<select id="SelectTEngineer_CV" parameterClass="System.Collections.IDictionary" resultMap="TEngineer.select-tengineer-result">
SELECT *
FROM t_engineer
<include refid="sql_TEngineer_where_cv"/><!--where-->
</select>

<insert id="InsertTEngineer" parameterClass="TEngineer">
<!--pre selectKey place-->
INSERT INTO t_engineer(
<dynamic prepend=" ">
    <isPropertyAvailable property="StfId" prepend=",">stf_id</isPropertyAvailable>
    <isPropertyAvailable property="StfName" prepend=",">stf_name</isPropertyAvailable>
    <isPropertyAvailable property="EngType" prepend=",">eng_type</isPropertyAvailable>
    <isPropertyAvailable property="EngAlias" prepend=",">eng_alias</isPropertyAvailable>
</dynamic>
)VALUES(
<dynamic prepend=" ">
    <isPropertyAvailable property="StfId" prepend=",">#StfId#</isPropertyAvailable>
    <isPropertyAvailable property="StfName" prepend=",">#StfName#</isPropertyAvailable>
    <isPropertyAvailable property="EngType" prepend=",">#EngType#</isPropertyAvailable>
    <isPropertyAvailable property="EngAlias" prepend=",">#EngAlias#</isPropertyAvailable>
</dynamic>
)
<selectKey resultClass="int" type="post" property="EngId" >
SELECT LAST_INSERT_ID()
</selectKey>
</insert>

<update id="UpdateTEngineer" parameterClass="System.Collections.IDictionary">
UPDATE t_engineer
<include refid="sql_TEngineer_set_cols"/><!--set-->
<include refid="sql_TEngineer_where_pk"/><!--where-->
</update>

<delete id="DeleteTEngineer" parameterClass="">
DELETE FROM t_engineer
<include refid="sql_TEngineer_where_pk"/><!--where-->
</delete>

<statement id="DeleteTEngineer_CV" parameterClass="TEngineer">
DELETE FROM t_engineer
<include refid="sql_TEngineer_where_cv"/><!--where-->
</statement>

<delete id="ClearTEngineer">
DELETE FROM t_engineer
</delete>
</statements>
</sqlMap>